<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>


  <script>
    let arr = []
    while (arr.length < 5) {
      let age = Number(prompt(`请输入第${arr.length + 1}年龄`))
      if (age > 0 && age < 100) {
        arr.push(age)
      }
    }

    // 打印成年人的年龄

    for (let i = 0; i < arr.length; i++) {
      if (arr[i] > 18) {
        console.log(arr[i])
      }
    }

    // 总年龄  平均年龄
    let total = 0
    let ava = 0
    for (let i = 0; i < arr.length; i++) {
      total += arr[i]
      ava = total / arr.length
    }
    console.log(total, ava);


    //  最大值和最小值
    let min = arr[0]
    let max = arr[0]
    for (let i = 0; i < arr.length; i++) {
      if (max < arr[i]) {
        max = arr[i]
      }
      if (min > arr[i]) {
        min = arr[i]
      }
    }
    console.log(min, max);



    // console.log(arr); 
  </script>
</body>

</html>